<script lang="ts" setup>
import { ref } from 'vue';
import CouponDetails from './components/coupon-details.vue';
import { onLoad } from '@dcloudio/uni-app';
import { useRouter } from '@/router';
import { getCouponDetailsById } from '@/api/user';
import { isWechat } from '@/utils/platform';

const router = useRouter();
const data = ref();

onLoad(async (options) => {
  getCouponDetailsById(options!.id).then((res) => {
    data.value = res.data;
  });
});
</script>

<template>
  <uni-nav-bar
    v-if="isWechat()"
    :border="false"
    :title="data?.couponName"
    fixed
    left-icon="left"
    status-bar
    @click-left="router.back"
  />
  <view class="p-3">
    <coupon-details
      :at-least="data?.atLeast"
      :desc="data?.pmsCouponType?.desc"
      :end-date="data?.endTime"
      :scene="data?.scene"
      :start-date="data?.startTime"
      :status="data?.state"
      :title="data?.couponName"
      :restaurant-ids="data?.restaurantIds"
      :restaurant-names="data?.restaurantNames"
      :property-ids="data?.propertyIds"
      :property-names="data?.propertyNames"
      :spa-service-type-str="data?.spaServiceTypeStr"
      :car-service-type-str="data?.carServiceTypeStr"
    />
  </view>
</template>
